//
//  pictureVC.m
//  项目一
//
//  Created by 芮京 on 2018/10/9.
//  Copyright © 2018 芮京. All rights reserved.
//

#import "pictureVC.h"

@interface pictureVC ()<UIScrollViewDelegate>
@property(nonatomic,strong)UIScrollView *scrollerview;
@property(nonatomic,strong)UILabel *numlabel;

@end

@implementation pictureVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor=[UIColor blackColor];
    
    //创建滚动式图
    [self createScroll];
    
    [self createdesview];
    
}
-(void)createdesview{
    UILabel *titlelabel=[[UILabel alloc] initWithFrame:CGRectMake(20, 600, WIDTH-120, 20)];
    titlelabel.textColor=[UIColor whiteColor];
    titlelabel.font=[UIFont systemFontOfSize:15];
    titlelabel.text=_model.setname;
    [self.view addSubview:titlelabel];
    
    
    UILabel *titlelabel1=[[UILabel alloc] initWithFrame:CGRectMake(20, 620, WIDTH-40, 100)];
    titlelabel1.textColor=[UIColor whiteColor];
    titlelabel1.font=[UIFont systemFontOfSize:12];
    titlelabel1.numberOfLines=0;
    titlelabel1.text=_model.desc;
    [self.view addSubview:titlelabel1];
    
    
    _numlabel =[[UILabel alloc] initWithFrame:CGRectMake(WIDTH-100, 600, 80, 20)];
    _numlabel.textColor=[UIColor whiteColor];
    _numlabel.font=[UIFont systemFontOfSize:13];
    _numlabel.text=[NSString stringWithFormat:@"1/%ld",_model.pics.count];
    _numlabel.textAlignment=NSTextAlignmentRight;
    [self.view addSubview:_numlabel];
    
    
}
//滚动式图
-(void)createScroll{
    
    self.scrollerview=[[UIScrollView alloc] initWithFrame:CGRectMake(0, 320, WIDTH, 250)];
    
    self.scrollerview.bounces=NO;
    self.scrollerview.pagingEnabled=YES;
    self.scrollerview.delegate=self;
    self.scrollerview.contentSize=CGSizeMake(WIDTH *_model.pics.count, 250);
    for (int i=0; i<_model.pics.count; i++) {
        UIImageView *img=[[UIImageView alloc] initWithFrame:CGRectMake(i*WIDTH, 0, WIDTH, 250)];
        [img sd_setImageWithURL:[NSURL URLWithString:_model.pics[i]]];
        [_scrollerview addSubview:img];
    }
    [self.view addSubview:_scrollerview];
    
}
//可变页数
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    
    
    _numlabel.text=[NSString stringWithFormat:@"%0.0f/%ld",(scrollView.contentOffset.x/WIDTH+1),_model.pics.count];
}
@end
